<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>用户信息列表</title>
<!-- 引入css -->
<link href="css/bootstrap.min.css" rel="stylesheet" />
<!-- 使用bootstrap前端框架，首先引入jquery -->
<script type="text/javascript" src="js/jquery-3.3.1.js"></script>
<!-- 引入js插件 -->
<script type="text/javascript" src="js/bootstrap.min.js"></script>
<script type="text/javascript">
	function doOut(){
		var flag = confirm("是否确认注销？");
		if(flag){
			window.location="UserServlet?method=out";
		}
	}
	function doDelete(uId){
		var flag = confirm("是否确认删除？");
		if(flag){
			window.location="UserServlet?method=delete&uId="+uId;
		}
	}
</script>
</head>
<body style="background:url('images/bg5.jpg');background-size:cover;">
	<div class="container" align="center">
	欢迎您，${user1.rName }&nbsp;&nbsp;<a href="javascript:doOut()">注销</a>&nbsp;&nbsp;
<!-- 	<button onclick="javascript:window.location.href='user/add.jsp'">添加用户信息</button> -->
	<br>
	<!-- url标签有跳转功能无需form表单跳转 -->
	<form action="UserServlet?method=select" method="post">
		昵称：<input name="uName" value="${uName }">
		真实姓名：<input name="rName" value="${rName }">
		手机号：<input name="tel" value="${tel }">
			<input type="submit" value="查询">
	</form>
		<table width="600" border="1" class="table table-striped">
		<tr>
			<th>编号</th>
			<th>账号</th>
			<th>真实姓名</th>
			<th>手机号</th>
			<th>操作</th>
		</tr>
		<c:forEach items="${list }" var="user" varStatus="status">
		<tr>
		<c:set value="${i+1 }" var="i"/>
			<td>${i }</td>
			<td>${user.uName}</td>
			<td>${user.rName}</td>
			<td>${user.tel}</td>
			<td>
				<a href="UserServlet?method=getUser&uId=${user.uId }">修改</a>&nbsp;&nbsp;
				<a href="javascript:doDelete(${user.uId })">删除</a>
			</td>
		</tr>
		</c:forEach>
	</table>
	
	<c:url value="UserServlet?method=select" var="first">
		<c:param name="pageIndex" value="1"></c:param>
		<c:param name="uName" value="${uName }"></c:param>
		<c:param name="rName" value="${rName }"></c:param>
		<c:param name="tel" value="${tel }"></c:param>
	</c:url>
	
	<c:url value="UserServlet?method=select" var="forward">
		<c:param name="pageIndex" value="${pageIndex-1 }"></c:param>
		<c:param name="pageIndex" value="1"></c:param>
		<c:param name="uName" value="${uName }"></c:param>
		<c:param name="rName" value="${rName }"></c:param>
		<c:param name="tel" value="${tel }"></c:param>
	</c:url>
	
	<c:url value="UserServlet?method=select" var="next">
		<c:param name="pageIndex" value="${pageIndex+1 }"></c:param>
		<c:param name="pageIndex" value="1"></c:param>
		<c:param name="uName" value="${uName }"></c:param>
		<c:param name="rName" value="${rName }"></c:param>
		<c:param name="tel" value="${tel }"></c:param>
	</c:url>
	
	<c:url value="UserServlet?method=select" var="last">
		<c:param name="pageIndex" value="${totalPages }"></c:param>
		<c:param name="pageIndex" value="1"></c:param>
		<c:param name="uName" value="${uName }"></c:param>
		<c:param name="rName" value="${rName }"></c:param>
		<c:param name="tel" value="${tel }"></c:param>
	</c:url>
	<font size="5">
	<a href="${first }">首页</a>
	<!-- 当前页码等于1时隐藏"上一页" -->
	<c:if test="${pageIndex > 1 }">
	<a href="${forward }">上一页</a>
	</c:if>
	<!-- 当前页码为总页码时，隐藏"下一页" -->
	<c:if test="${pageIndex < totalPages }">
	<a href="${next }">下一页</a>
	</c:if>
	<a href="${last }">尾页</a>
	&nbsp;&nbsp;&nbsp;&nbsp;总共${totalCounts }条数据，第${pageIndex }页/共${totalPages }页
	</font></div>
</body>
</html>